//
// Created by wangliewei on 2021/8/13.
//
#include<iostream>
using namespace std;

const int N = 100010;

int a[N], s[N];

int main(){

    int n, m;
    cin>>n>>m;
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
        s[i] = s[i - 1] + a[i];
    }
    while (m--) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", s[r] - s[l - 1]);
    }

    return 0;
}
